package com.young.springdemo.service.component;

import java.util.ArrayList;
import java.util.List;

//文件夹
public class Folder extends Component{

    List<Component> folders = new ArrayList<>();

    private String name;

    public Folder(String name) {
        this.name = name;
    }

    @Override
    public void add(Component component) {
        folders.add(component);
    }

    @Override
    public void remove(Component component) {
        folders.remove(component);
    }

    @Override
    public Component get(int i) {
        return folders.get(i);
    }

    @Override
    public void killVirus() {
        System.out.println("******开始对文件夹"+name+"进行杀毒");
        for (Component component : folders){
            component.killVirus();
        }
    }
}
